using IcsSEMCtrl.Event;
using IcsSEMCtrl.Service.Logger;
using IcsSEMCtrl.Util.Client;
using Lifter.Device;
using Lifter.Event.Lifter;
using Lifter.Global;
using Lifter.Gui.Monitor.Controls;
using Lifter.Utility;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Threading;
using System.Windows.Forms;
using TKT.Lifter.CIM.Lifter.Event.Lifter;
using TKT.Lifter.CIM.Lifter.Global;
using TKT.Lifter.CIM.Lifter.Gui.Monitor.Panels;
using TKT.Lifter.CIM.Lifter.Gui.Monitor.Popups;

namespace Lifter.Gui.Monitor.Panels
{
    public class MainTopPanel : ControlBase
    {
        private delegate void RedrawDelegate();
        private delegate void delegateUpdateMainTopPanelPanel();
        private delegate void delegateCimStatus();
        private class SCStateChangeAdapter : ECPEventAdapter
        {
            public SCStateChangeAdapter()
            {
                base.Subscribe();
            }
            public override string GetSubscriptionSubject()
            {
                return SCStateModeEvent.FormSubject("*");
            }
            public override void ReceiveECPEvent(ECPEvent ecpEvent)
            {
                //更新设备模式（/AUTO/PAUED/PAUSING）
                MainTopPanel.UpDateSCStateMode(ecpEvent);
            }
        }
        private class MPLCConnectionAdapter : ECPEventAdapter
        {
            public MPLCConnectionAdapter()
            {
                base.Subscribe();
            }
            public override string GetSubscriptionSubject()
            {
                return LifterPLCConnectionEvent.FormSubject("*");
            }
            public override void ReceiveECPEvent(ECPEvent ecpEvent)
            {
                //更新PLC连接状态
                MainTopPanel.UpDatePLCConnection(ecpEvent);
            }
        }
        private class HostControlStateChangeAdapter : ECPEventAdapter
        {
            public HostControlStateChangeAdapter()
            {
                base.Subscribe();
            }
            public override string GetSubscriptionSubject()
            {
                return HostControlStateEvent.FormSubject("*");
            }
            public override void ReceiveECPEvent(ECPEvent ecpEvent)
            {
                //更新Host控制状态
                MainTopPanel.UpDateHostControlState(ecpEvent);
            }
        }
        /// <summary>
        /// Cim状态的订阅事件
        /// </summary>
        private class CimStatusAdapter : ECPEventAdapter
        {
            public CimStatusAdapter()
            {
                base.Subscribe();
            }
            public override string GetSubscriptionSubject()
            {
                return CimStatusEvent.FormSubject("*");
            }
            public override void ReceiveECPEvent(ECPEvent ecpEvent)
            {
                MainTopPanel.UpDateCimStatus(ecpEvent);
            }
        }

        private static Dictionary<string, MainTopPanel> MainTopPanelbyName = new Dictionary<string, MainTopPanel>();
        private static MainTopPanel.SCStateChangeAdapter sCStateChangeAdapter = null;
        private static MainTopPanel.HostControlStateChangeAdapter controlStateChangeAdapter = null;
        private static MainTopPanel.MPLCConnectionAdapter mPLCConnectionAdapter = null;
        private static MainTopPanel.CimStatusAdapter cimStatusAdapter = null;
        private LifterSEM hostDevice = null;
        //private Timer timerRefresh = new Timer();
        private string equipmentName = "";
        private enumSCStateMode sCStateMode = enumSCStateMode.SC_PAUSED;
        private enumHostControlState hostControlState = enumHostControlState.SC_OFFLINE_HOST;
        private enumCimStatus cimStatus = enumCimStatus.OFF;
        private bool isPLCConnection = false;
        public enumSCStateMode    currentSCStateMode = enumSCStateMode.SC_PAUSED;
        public enumHostControlState currentHostControlState = enumHostControlState.SC_OFFLINE_HOST;
        public bool currentIsPLCConnection = false;
        private IContainer components = null;
        private SCStateControl scStateControl;
        private DateTimeControl dateTimeControl1;
        private CommunicationStateControl communicationStateControl;
        private LifterIDControl DeviceControl1;
        private Label labelLifterName;
        private UISmoothLabel uiSmoothLabel2;
        public TableLayoutPanel tableLayoutPanel1;
        private UISymbolLabel lbMachineName;
        private UISymbolLabel uiSymbolLabel2;
        private UISymbolLabel uiSymbolLabel3;
        private UISymbolLabel uiSymbolLabel4;
        private UISymbolLabel uiSymbolLabel5;
        private TableLayoutPanel tableLayoutPanel2;
        private UISymbolButton btnOnOffline;
        private UISymbolButton btnLogin;
        public UILabel lbUserName;
        private UISymbolLabel uiCimStatue;
        private UILabel lbCimStatus;
        private UILabel lblPLCConnection;
        public new event MainTopPanelEvent Click;
        public string EquipmentName
        {
            get
            {
                return this.equipmentName;
            }
            set
            {
                this.equipmentName = value;
                if (value != "")
                {
                    this.labelLifterName.Text = value;
                }
            }
        }
        public enumSCStateMode SCStateMode
        {
            get
            {
                return this.sCStateMode;
            }
            set
            {
                this.sCStateMode = value;
                this.hostDevice.sCStatemode = value;
                switch (this.sCStateMode)
                {
                    case enumSCStateMode.SC_INIT:
                        this.scStateControl.ScState = SCStateControl.SCSTATE.SCINIT;
                        break;
                    case enumSCStateMode.SC_PAUSED:
                        this.scStateControl.ScState = SCStateControl.SCSTATE.PAUSED;
                        break;
                    case enumSCStateMode.SC_AUTO:
                        this.scStateControl.ScState = SCStateControl.SCSTATE.AUTO;
                        break;
                    case enumSCStateMode.SC_PAUSING:
                        this.scStateControl.ScState = SCStateControl.SCSTATE.PAUSING;
                        break;
                }
            }
        }
        public enumHostControlState HostControlState
        {
            get
            {
                return this.hostControlState;
            }
            set
            {
                this.hostControlState = value;
            }
        }
        public enumCimStatus CimStatus
        {
            get
            {
                return this.cimStatus;
            }
            set
            {
                this.cimStatus = value;
            }
        }
        public bool IsPLCConnection
        {
            get
            {
                return this.isPLCConnection;
            }
            set
            {
                this.isPLCConnection = value;
            }
        }
        public void Subscribe()
        {
            if (MainTopPanel.sCStateChangeAdapter == null)
            {
                MainTopPanel.sCStateChangeAdapter = new MainTopPanel.SCStateChangeAdapter();
            }
            if (MainTopPanel.controlStateChangeAdapter == null)
            {
                MainTopPanel.controlStateChangeAdapter = new MainTopPanel.HostControlStateChangeAdapter();
            }
            if (MainTopPanel.mPLCConnectionAdapter == null)
            {
                MainTopPanel.mPLCConnectionAdapter = new MainTopPanel.MPLCConnectionAdapter();
            }
            if (MainTopPanel.cimStatusAdapter == null)
            {
                MainTopPanel.cimStatusAdapter = new MainTopPanel.CimStatusAdapter();
            }
            if (!MainTopPanel.MainTopPanelbyName.ContainsKey(this.hostDevice.ElementId))
            {
                MainTopPanel.MainTopPanelbyName.Add(this.hostDevice.ElementId, this);
            }
        }
        public MainTopPanel()
        {
            this.InitializeComponent();
/*            this.timerRefresh.Interval = 1000;
            this.timerRefresh.Enabled = true;*/
            this.scStateControl.ScState = SCStateControl.SCSTATE.PAUSED;
            try
            {
                this.hostDevice = (LifterSEM)Naming.GetDeviceManager().GetDevice();
                this.EquipmentName = String.Format("{0} Ver{1}", "自动化Lifter CIM系统", Application.ProductVersion);//this.hostDevice.HostID;
                this.DeviceControl1.EquipMentId = this.hostDevice.HostID;
                this.Subscribe();
            }
            catch (NullReferenceException)
            {
            }
            //this.timerRefresh.Tick += new EventHandler(this.timerRefresh_Tick);
        }
        private void timerRefresh_Tick(object sender, EventArgs e)
        {
            try
            {
                if (this.hostDevice.SecsDriver.IsConnected)
                {
                    switch (this.hostDevice.HostControlState)
                    {
                        case enumHostControlState.SC_OFFLINE_HOST:
                            this.communicationStateControl.CommunicationState = CommunicationStateControl.COMMUNICATION_STATE.HOST_OFFLINE;
                            break;
                        case enumHostControlState.SC_LOCAL:
                            this.communicationStateControl.CommunicationState = CommunicationStateControl.COMMUNICATION_STATE.ONLINE_LOCAL;
                            break;
                        case enumHostControlState.SC_ONLINE_HOST:
                            this.communicationStateControl.CommunicationState = CommunicationStateControl.COMMUNICATION_STATE.ONLINE_REMOTE;
                            break;
                    }
                }
                else
                {
                    this.communicationStateControl.CommunicationState = CommunicationStateControl.COMMUNICATION_STATE.DISCONNET;
                }
            }
            catch (Exception ex)
            { }
        }
        public void UpdateDelegate()
        {
            base.BeginInvoke(new MainTopPanel.delegateUpdateMainTopPanelPanel(this.UpdateMainTopPanel));
        }
        public void UpdateMainTopPanel()
        {
            LifterSEM lifterSEM = (LifterSEM)Naming.GetDeviceManager().GetDevice();
            if (lifterSEM.IsPLCConnected)
            {
                this.lblPLCConnection.Text = "Connected";
                this.lblPLCConnection.ForeColor = Color.LimeGreen;
            }
            else
            {
                this.lblPLCConnection.Text = "DisConnected";
                this.lblPLCConnection.ForeColor = Color.Red;
            }
            if (this.hostDevice.SecsDriver.IsConnected)
            {
                switch (this.HostControlState)
                {
                    case enumHostControlState.SC_OFFLINE_HOST:
                        this.communicationStateControl.CommunicationState = CommunicationStateControl.COMMUNICATION_STATE.HOST_OFFLINE;
                        break;
                    case enumHostControlState.SC_LOCAL:
                        this.communicationStateControl.CommunicationState = CommunicationStateControl.COMMUNICATION_STATE.ONLINE_LOCAL;
                        break;
                    case enumHostControlState.SC_ONLINE_HOST:
                        this.communicationStateControl.CommunicationState = CommunicationStateControl.COMMUNICATION_STATE.ONLINE_REMOTE;
                        break;
                }
            }
            else
            {
                this.communicationStateControl.CommunicationState = CommunicationStateControl.COMMUNICATION_STATE.DISCONNET;
            }
        }
        /// <summary>
        /// Cim状态的异步处理
        /// </summary>
        public void CimStatusDelegate()
        {
            var MethInvo = new delegateCimStatus(EventCimStatus);
            this.BeginInvoke(MethInvo);
        }
        /// <summary>
        /// Cim状态改变
        /// </summary>
        public void EventCimStatus()
        {
            LifterSEM lifterSEM = (LifterSEM)Naming.GetDeviceManager().GetDevice();
            if (lifterSEM.CimStatus == enumCimStatus.ON)
            {
                this.lbCimStatus.Text = "ON";
                this.lbCimStatus.ForeColor = Color.LimeGreen;
            }
            else
            {
                this.lbCimStatus.Text = "OFF";
                this.lbCimStatus.ForeColor = Color.Red;
            }
        }
        protected virtual void ClickEventRaised(object sender, MainTopPanelEventArgs e)
        {
            if (this.Click != null)
            {
                this.Click(sender, e);
            }
        }
        private void btnOnOffline_Click(object sender, EventArgs e)
        {
            this.ClickEventRaised(sender, new MainTopPanelEventArgs(MainTopPanelEventArgs.TOP_MENU_INDEX.OnOffline));
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            this.ClickEventRaised(sender, new MainTopPanelEventArgs(MainTopPanelEventArgs.TOP_MENU_INDEX.Login));
        }
        public static void UpDatePLCConnection(ECPEvent ecpEvent)
        {
            if (LifterMainForm.PlaybackMode)
            {
                return;
            }
            LifterPLCConnectionEvent lifterPLCConnectionEvent = (LifterPLCConnectionEvent)ecpEvent;
            if (MainTopPanel.MainTopPanelbyName.ContainsKey(lifterPLCConnectionEvent.DeviceID))
            {
                MainTopPanel mainTopPanel = MainTopPanel.MainTopPanelbyName[lifterPLCConnectionEvent.DeviceID];
                mainTopPanel.isPLCConnection = lifterPLCConnectionEvent.IsPLCConnection;
                mainTopPanel.UpdateDelegate();
            }
        }
        public static void UpDateHostControlState(ECPEvent ecpEvent)
        {
            if (LifterMainForm.PlaybackMode)
            {
                return;
            }
            HostControlStateEvent hostControlStateEvent = (HostControlStateEvent)ecpEvent;
            if (MainTopPanel.MainTopPanelbyName.ContainsKey(hostControlStateEvent.DeviceID))
            {
                MainTopPanel mainTopPanel = MainTopPanel.MainTopPanelbyName[hostControlStateEvent.DeviceID];
                mainTopPanel.HostControlState = hostControlStateEvent.HostControlState;
                mainTopPanel.UpdateDelegate();
            }
        }
        /// <summary>
        /// Cim状态的数据传输
        /// </summary>
        /// <param name="ecpEvent"></param>
        public static void UpDateCimStatus(ECPEvent ecpEvent)
        {
            if (LifterMainForm.PlaybackMode)
            {
                return;
            }
            CimStatusEvent cimStatusEvent = (CimStatusEvent)ecpEvent;
            if (MainTopPanel.MainTopPanelbyName.ContainsKey(cimStatusEvent.DeviceID))
            {
                MainTopPanel mainTopPanel = MainTopPanel.MainTopPanelbyName[cimStatusEvent.DeviceID];
                mainTopPanel.CimStatus = cimStatusEvent.CimStatus;
                mainTopPanel.CimStatusDelegate();
            }
        }
        public static void UpDateSCStateMode(ECPEvent ecpEvent)
        {
            if (LifterMainForm.PlaybackMode)
            {
                return;
            }
            SCStateModeEvent sCStateModeEvent = (SCStateModeEvent)ecpEvent;
            if (MainTopPanel.MainTopPanelbyName.ContainsKey(sCStateModeEvent.DeviceID))
            {
                MainTopPanel mainTopPanel = MainTopPanel.MainTopPanelbyName[sCStateModeEvent.DeviceID];
                mainTopPanel.sCStateMode = sCStateModeEvent.SCStateMode;
                mainTopPanel.SCStateModeDelegate();
            }
        }
        public string GetTopPanelState()
        {
            return "State@" + ((int)SCStateMode).ToString() + "@" + (isPLCConnection ? "1" : "0") + "@" + ((int)HostControlState).ToString() + "@" + ((int)CimStatus).ToString() + "/";
        }
        public void UpdatePlaybackState(string stateString)
        {
            if (!LifterMainForm.PlaybackMode)
            {
                return;
            }

            string[] strArray = stateString.Split(new char[] { '@' }, StringSplitOptions.RemoveEmptyEntries);
            this.SCStateMode = (enumSCStateMode)Convert.ToInt32(strArray[0]);
            this.IsPLCConnection = strArray[1] == "1" ? true : false;
            this.HostControlState = (enumHostControlState)Convert.ToInt32(strArray[2]);
            this.UpdateDelegate();
        }
        public static void LogInOutChage(bool value)
        {
            MainTopPanel mainTopPanel = (MainTopPanel)SimpleCache.GetObject("FormMain", "MainTopPanel");
            mainTopPanel.OnLoginChange(value);
        }
        private void OnLoginChange(bool value)
        {
            if (value)
            {
                this.btnLogin.Symbol = 57453;
                this.btnLogin.Text = "Logout";
            }
            else
            {
                this.btnLogin.Symbol = 57452;
                this.btnLogin.Text = "Login";
            }
        }
        private void labelLifterName_DoubleClick(object sender, EventArgs e)
        {
            Graphics graphics = Graphics.FromHwnd(base.ParentForm.Handle);
            Rectangle bounds = Screen.PrimaryScreen.Bounds;
            Bitmap bitmap = this.CaptureScreen(this, bounds);
            ImageFormat png = ImageFormat.Png;
            try
            {
                string text = "C:\\LifterCapture\\";
                string text2 = string.Concat(new string[]
                {
                    this.hostDevice.HostID,
                    "_",
                    DateTime.Now.ToString("yyyy-MM-dd HH.mm.ss.fff"),
                    ".",
                    png.ToString().ToLower()
                });
                if (!Directory.Exists(text))
                {
                    Directory.CreateDirectory(text);
                }
                if (bitmap != null)
                {
                    bitmap.Save(text + text2, png);
                }
            }
            catch (Exception)
            {
            }
        }
        private Bitmap CaptureScreen(Control wnd, Rectangle rc)
        {
            Bitmap result;
            if (rc.Width > 0 && rc.Height > 0)
            {
                Bitmap bitmap = null;
                Image[] array = new Bitmap[1];
                using (Graphics graphics = wnd.CreateGraphics())
                {
                    bitmap = new Bitmap(rc.Width, rc.Height, graphics);
                    using (Graphics graphics2 = Graphics.FromImage(bitmap))
                    {
                        graphics2.CopyFromScreen(rc.X, rc.Y, 0, 0, rc.Size, CopyPixelOperation.SourceCopy);
                    }
                }
                array[0] = bitmap;
                result = bitmap;
            }
            else
            {
                result = null;
            }
            return result;
        }
        private void labelLifterName_Click(object sender, EventArgs e)
        {
        }
        private void scStateControl_DoubleClick(object sender, EventArgs e)
        {
            LifterSEM lifterSEM = (LifterSEM)Naming.GetDeviceManager().GetDevice();
            switch (this.scStateControl.ScState)
            {
                case SCStateControl.SCSTATE.PAUSED:
                    if (lifterSEM.DeviceState == enumRIDState.DOWN)
                    {
                        PopupNotice.DialogPopups("Lifter是DOWN状态. 不能改变为AUTO模式！！！", "Lifter is the DOWN state Cannot change to AUTO mode!!!", enumPopupsType.Warning);
                    }
                    else
                    {
                        string message;
                        if (lifterSEM.LanguageType.Equals("zh"))
                        {
                            message = "请确认是否将模式改为AUTO？";
                        }
                        else
                        {
                            message = "Please confirm whether to change the mode to AUTO？";
                        }

                        if (UIMessageDialog.ShowMessageDialog(message, UILocalize.AskTitle, showCancelButton: true, UIStyle.Blue, false))
                        {
                            lifterSEM.O_RESUMEREQ = true;//复位请求
                            LogHelper.operationLogger(string.Format("用户[{0}]进行了设备AUTO模式切换操作", this.hostDevice.UserName));
                            lifterSEM.InsertUserOperation(lifterSEM.UserName, string.Format("用户[{0}]进行了设备AUTO模式切换操作", this.hostDevice.UserName));
                        }
                        else
                        {
                            return;
                        }
                    }
                    break;
                case SCStateControl.SCSTATE.AUTO:
                    if (lifterSEM.DeviceState == enumRIDState.DOWN)
                    {
                        PopupNotice.DialogPopups("Lifter是DOWN状态. 不能改变为PAUSE模式！！！", "Lifter is the DOWN state Cannot change to PAUSE mode!!!", enumPopupsType.Warning);
                    }
                    else
                    {
                        string message;
                        if (lifterSEM.LanguageType.Equals("zh"))
                        {
                            message = "请确认是否将模式改为PAUSE？";
                        }
                        else
                        {
                            message = "Please confirm whether to change the mode to PASUE？";
                        }

                        if (UIMessageDialog.ShowMessageDialog(message, UILocalize.AskTitle, showCancelButton: true, UIStyle.Blue, false))
                        {
                            lifterSEM.O_PAUSEREQ = true;//暂停请求
                            SCStateMode = enumSCStateMode.SC_PAUSING;
                            LogHelper.operationLogger(string.Format("用户[{0}]进行了设备PAUSE模式切换操作", this.hostDevice.UserName));
                            lifterSEM.InsertUserOperation(lifterSEM.UserName, string.Format("用户[{0}]进行了设备PAUSE模式切换操作", this.hostDevice.UserName));
                        }
                        else
                        {
                            return;
                        }
                    }
                    break;
            }
        }
        public void SCStateModeDelegate()
        {
            this.BeginInvoke(new delegateCimStatus(StateMode));
        }
        //设备复位sCStatemode
        public void StateMode()
        {
            LifterSEM lifterSEM = (LifterSEM)Naming.GetDeviceManager().GetDevice();
            if(lifterSEM.SCStatemode == enumSCStateMode.SC_PAUSED)
            {
                this.SCStateMode = enumSCStateMode.SC_PAUSED;
                lock (LifterSEM.alarmMonitor)
                {
                    lifterSEM.ReportAlarms.Clear();
                }
                UserManageControl.userManageControl.UpdateAlarms(lifterSEM.ReportAlarms);
                return;
            }
            if (lifterSEM.SCStatemode == enumSCStateMode.SC_AUTO)
            {
                this.SCStateMode = enumSCStateMode.SC_AUTO;
                lock (LifterSEM.alarmMonitor)
                {
                    lifterSEM.ReportAlarms.Clear();
                }
                UserManageControl.userManageControl.UpdateAlarms(lifterSEM.ReportAlarms);
            }
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing && this.components != null)
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }
        private void InitializeComponent()
        {
            this.DeviceControl1 = new Lifter.Gui.Monitor.Controls.LifterIDControl();
            this.communicationStateControl = new Lifter.Gui.Monitor.Controls.CommunicationStateControl();
            this.dateTimeControl1 = new Lifter.Gui.Monitor.Controls.DateTimeControl();
            this.scStateControl = new Lifter.Gui.Monitor.Controls.SCStateControl();
            this.labelLifterName = new System.Windows.Forms.Label();
            this.uiSmoothLabel2 = new Sunny.UI.UISmoothLabel();
            this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
            this.lbMachineName = new Sunny.UI.UISymbolLabel();
            this.uiSymbolLabel3 = new Sunny.UI.UISymbolLabel();
            this.uiSymbolLabel4 = new Sunny.UI.UISymbolLabel();
            this.uiSymbolLabel5 = new Sunny.UI.UISymbolLabel();
            this.lblPLCConnection = new Sunny.UI.UILabel();
            this.lbUserName = new Sunny.UI.UILabel();
            this.uiSymbolLabel2 = new Sunny.UI.UISymbolLabel();
            this.uiCimStatue = new Sunny.UI.UISymbolLabel();
            this.lbCimStatus = new Sunny.UI.UILabel();
            this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
            this.btnLogin = new Sunny.UI.UISymbolButton();
            this.btnOnOffline = new Sunny.UI.UISymbolButton();
            this.panelBack.SuspendLayout();
            this.panelContent.SuspendLayout();
            this.tableLayoutPanel1.SuspendLayout();
            this.tableLayoutPanel2.SuspendLayout();
            this.SuspendLayout();
            // 
            // panelBack
            // 
            this.panelBack.Padding = new System.Windows.Forms.Padding(0);
            this.panelBack.Size = new System.Drawing.Size(1172, 66);
            // 
            // panelContent
            // 
            this.panelContent.Controls.Add(this.tableLayoutPanel1);
            this.panelContent.Controls.Add(this.uiSmoothLabel2);
            this.panelContent.Controls.Add(this.labelLifterName);
            this.panelContent.Controls.Add(this.dateTimeControl1);
            this.panelContent.Controls.Add(this.tableLayoutPanel2);
            this.panelContent.Location = new System.Drawing.Point(0, 0);
            this.panelContent.Size = new System.Drawing.Size(1172, 66);
            this.panelContent.TabIndex = 1;
            // 
            // DeviceControl1
            // 
            this.DeviceControl1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.DeviceControl1.BorderWith = 0;
            this.DeviceControl1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.DeviceControl1.EquipMentId = "TLFT9900";
            this.DeviceControl1.FillBrush = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.DeviceControl1.ForeColor = System.Drawing.Color.Crimson;
            this.DeviceControl1.Location = new System.Drawing.Point(1, 32);
            this.DeviceControl1.Margin = new System.Windows.Forms.Padding(0);
            this.DeviceControl1.Name = "DeviceControl1";
            this.DeviceControl1.Size = new System.Drawing.Size(138, 33);
            this.DeviceControl1.TabIndex = 0;
            this.DeviceControl1.Text = "DeviceControl";
            // 
            // communicationStateControl
            // 
            this.communicationStateControl.BorderWith = 0;
            this.communicationStateControl.CommunicationState = Lifter.Gui.Monitor.Controls.CommunicationStateControl.COMMUNICATION_STATE.DISCONNET;
            this.communicationStateControl.Dock = System.Windows.Forms.DockStyle.Fill;
            this.communicationStateControl.Font = new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.communicationStateControl.Interval = 500;
            this.communicationStateControl.IsBlink = false;
            this.communicationStateControl.Location = new System.Drawing.Point(143, 35);
            this.communicationStateControl.Name = "communicationStateControl";
            this.communicationStateControl.Size = new System.Drawing.Size(128, 27);
            this.communicationStateControl.TabIndex = 1;
            this.communicationStateControl.Text = "communicationStateControl1";
            // 
            // dateTimeControl1
            // 
            this.dateTimeControl1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.dateTimeControl1.BorderWith = 0;
            this.dateTimeControl1.Dock = System.Windows.Forms.DockStyle.Right;
            this.dateTimeControl1.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.dateTimeControl1.ForeColor = System.Drawing.Color.White;
            this.dateTimeControl1.Location = new System.Drawing.Point(932, 0);
            this.dateTimeControl1.Name = "dateTimeControl1";
            this.dateTimeControl1.Size = new System.Drawing.Size(120, 66);
            this.dateTimeControl1.TabIndex = 2;
            this.dateTimeControl1.Text = "dateTimeControl1";
            // 
            // scStateControl
            // 
            this.scStateControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.scStateControl.BorderWith = 0;
            this.scStateControl.Dock = System.Windows.Forms.DockStyle.Fill;
            this.scStateControl.Interval = 500;
            this.scStateControl.Location = new System.Drawing.Point(543, 35);
            this.scStateControl.Name = "scStateControl";
            this.scStateControl.ScState = Lifter.Gui.Monitor.Controls.SCStateControl.SCSTATE.SCINIT;
            this.scStateControl.Size = new System.Drawing.Size(117, 27);
            this.scStateControl.TabIndex = 3;
            this.scStateControl.Text = "scStateControl1";
            this.scStateControl.DoubleClick += new System.EventHandler(this.scStateControl_DoubleClick);
            // 
            // labelLifterName
            // 
            this.labelLifterName.BackColor = System.Drawing.Color.AliceBlue;
            this.labelLifterName.Font = new System.Drawing.Font("等线", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.labelLifterName.ForeColor = System.Drawing.Color.MediumBlue;
            this.labelLifterName.Location = new System.Drawing.Point(722, 0);
            this.labelLifterName.Name = "labelLifterName";
            this.labelLifterName.Size = new System.Drawing.Size(105, 66);
            this.labelLifterName.TabIndex = 89;
            this.labelLifterName.Text = "自动化Lifter CIM系统";
            this.labelLifterName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            this.labelLifterName.Visible = false;
            this.labelLifterName.Click += new System.EventHandler(this.labelLifterName_Click);
            this.labelLifterName.DoubleClick += new System.EventHandler(this.labelLifterName_DoubleClick);
            // 
            // uiSmoothLabel2
            // 
            this.uiSmoothLabel2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.uiSmoothLabel2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.uiSmoothLabel2.Dock = System.Windows.Forms.DockStyle.Left;
            this.uiSmoothLabel2.Font = new System.Drawing.Font("微软雅黑 Light", 22F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.uiSmoothLabel2.ForeColor = System.Drawing.Color.Transparent;
            this.uiSmoothLabel2.Location = new System.Drawing.Point(0, 0);
            this.uiSmoothLabel2.Name = "uiSmoothLabel2";
            this.uiSmoothLabel2.RectColor = System.Drawing.Color.White;
            this.uiSmoothLabel2.RectSize = 3;
            this.uiSmoothLabel2.Size = new System.Drawing.Size(130, 66);
            this.uiSmoothLabel2.Style = Sunny.UI.UIStyle.Custom;
            this.uiSmoothLabel2.TabIndex = 98;
            this.uiSmoothLabel2.Text = "Visionox";
            this.uiSmoothLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            this.uiSmoothLabel2.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.uiSmoothLabel2.DoubleClick += new System.EventHandler(this.uiSmoothLabel2_DoubleClick);
            // 
            // tableLayoutPanel1
            // 
            this.tableLayoutPanel1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Single;
            this.tableLayoutPanel1.ColumnCount = 6;
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 17.39799F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.95283F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 17.08901F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.20141F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 15.55866F));
            this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 16.8001F));
            this.tableLayoutPanel1.Controls.Add(this.lbMachineName, 0, 0);
            this.tableLayoutPanel1.Controls.Add(this.scStateControl, 4, 1);
            this.tableLayoutPanel1.Controls.Add(this.uiSymbolLabel3, 1, 0);
            this.tableLayoutPanel1.Controls.Add(this.uiSymbolLabel4, 5, 0);
            this.tableLayoutPanel1.Controls.Add(this.uiSymbolLabel5, 4, 0);
            this.tableLayoutPanel1.Controls.Add(this.DeviceControl1, 0, 1);
            this.tableLayoutPanel1.Controls.Add(this.communicationStateControl, 1, 1);
            this.tableLayoutPanel1.Controls.Add(this.lblPLCConnection, 2, 1);
            this.tableLayoutPanel1.Controls.Add(this.lbUserName, 5, 1);
            this.tableLayoutPanel1.Controls.Add(this.uiSymbolLabel2, 2, 0);
            this.tableLayoutPanel1.Controls.Add(this.uiCimStatue, 3, 0);
            this.tableLayoutPanel1.Controls.Add(this.lbCimStatus, 3, 1);
            this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
            this.tableLayoutPanel1.Location = new System.Drawing.Point(130, 0);
            this.tableLayoutPanel1.Name = "tableLayoutPanel1";
            this.tableLayoutPanel1.RowCount = 2;
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 49.20635F));
            this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.79365F));
            this.tableLayoutPanel1.Size = new System.Drawing.Size(802, 66);
            this.tableLayoutPanel1.TabIndex = 99;
            // 
            // lbMachineName
            // 
            this.lbMachineName.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lbMachineName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.lbMachineName.ForeColor = System.Drawing.Color.White;
            this.lbMachineName.ImageInterval = 6;
            this.lbMachineName.Location = new System.Drawing.Point(4, 4);
            this.lbMachineName.MinimumSize = new System.Drawing.Size(1, 1);
            this.lbMachineName.Name = "lbMachineName";
            this.lbMachineName.Padding = new System.Windows.Forms.Padding(36, 0, 0, 0);
            this.lbMachineName.ShowFocusColor = true;
            this.lbMachineName.Size = new System.Drawing.Size(132, 24);
            this.lbMachineName.Style = Sunny.UI.UIStyle.Custom;
            this.lbMachineName.Symbol = 362729;
            this.lbMachineName.SymbolColor = System.Drawing.Color.White;
            this.lbMachineName.TabIndex = 40;
            this.lbMachineName.Text = "设备名";
            this.lbMachineName.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // uiSymbolLabel3
            // 
            this.uiSymbolLabel3.Dock = System.Windows.Forms.DockStyle.Fill;
            this.uiSymbolLabel3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.uiSymbolLabel3.ForeColor = System.Drawing.Color.White;
            this.uiSymbolLabel3.ImageInterval = 6;
            this.uiSymbolLabel3.Location = new System.Drawing.Point(143, 4);
            this.uiSymbolLabel3.MinimumSize = new System.Drawing.Size(1, 1);
            this.uiSymbolLabel3.Name = "uiSymbolLabel3";
            this.uiSymbolLabel3.Padding = new System.Windows.Forms.Padding(36, 0, 0, 0);
            this.uiSymbolLabel3.Size = new System.Drawing.Size(128, 24);
            this.uiSymbolLabel3.Style = Sunny.UI.UIStyle.Custom;
            this.uiSymbolLabel3.Symbol = 362728;
            this.uiSymbolLabel3.SymbolColor = System.Drawing.Color.White;
            this.uiSymbolLabel3.TabIndex = 43;
            this.uiSymbolLabel3.Text = "HOST状态";
            this.uiSymbolLabel3.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // uiSymbolLabel4
            // 
            this.uiSymbolLabel4.Dock = System.Windows.Forms.DockStyle.Fill;
            this.uiSymbolLabel4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.uiSymbolLabel4.ForeColor = System.Drawing.Color.White;
            this.uiSymbolLabel4.ImageInterval = 6;
            this.uiSymbolLabel4.Location = new System.Drawing.Point(667, 4);
            this.uiSymbolLabel4.MinimumSize = new System.Drawing.Size(1, 1);
            this.uiSymbolLabel4.Name = "uiSymbolLabel4";
            this.uiSymbolLabel4.Padding = new System.Windows.Forms.Padding(36, 0, 0, 0);
            this.uiSymbolLabel4.Size = new System.Drawing.Size(131, 24);
            this.uiSymbolLabel4.Style = Sunny.UI.UIStyle.Custom;
            this.uiSymbolLabel4.Symbol = 57454;
            this.uiSymbolLabel4.SymbolColor = System.Drawing.Color.White;
            this.uiSymbolLabel4.TabIndex = 44;
            this.uiSymbolLabel4.Text = "登录用户";
            this.uiSymbolLabel4.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // uiSymbolLabel5
            // 
            this.uiSymbolLabel5.Dock = System.Windows.Forms.DockStyle.Fill;
            this.uiSymbolLabel5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.uiSymbolLabel5.ForeColor = System.Drawing.Color.White;
            this.uiSymbolLabel5.ImageInterval = 3;
            this.uiSymbolLabel5.Location = new System.Drawing.Point(543, 4);
            this.uiSymbolLabel5.MinimumSize = new System.Drawing.Size(1, 1);
            this.uiSymbolLabel5.Name = "uiSymbolLabel5";
            this.uiSymbolLabel5.Padding = new System.Windows.Forms.Padding(30, 0, 0, 0);
            this.uiSymbolLabel5.Size = new System.Drawing.Size(117, 24);
            this.uiSymbolLabel5.Style = Sunny.UI.UIStyle.Custom;
            this.uiSymbolLabel5.Symbol = 362060;
            this.uiSymbolLabel5.SymbolColor = System.Drawing.Color.White;
            this.uiSymbolLabel5.TabIndex = 45;
            this.uiSymbolLabel5.Text = "设备状态";
            this.uiSymbolLabel5.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // lblPLCConnection
            // 
            this.lblPLCConnection.AutoSize = true;
            this.lblPLCConnection.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lblPLCConnection.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblPLCConnection.ForeColor = System.Drawing.Color.Red;
            this.lblPLCConnection.Location = new System.Drawing.Point(278, 32);
            this.lblPLCConnection.Name = "lblPLCConnection";
            this.lblPLCConnection.Size = new System.Drawing.Size(129, 33);
            this.lblPLCConnection.Style = Sunny.UI.UIStyle.Custom;
            this.lblPLCConnection.StyleCustomMode = true;
            this.lblPLCConnection.TabIndex = 90;
            this.lblPLCConnection.Text = "Disconnected";
            this.lblPLCConnection.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            this.lblPLCConnection.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // lbUserName
            // 
            this.lbUserName.AutoSize = true;
            this.lbUserName.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lbUserName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.lbUserName.ForeColor = System.Drawing.Color.White;
            this.lbUserName.Location = new System.Drawing.Point(667, 32);
            this.lbUserName.Name = "lbUserName";
            this.lbUserName.Size = new System.Drawing.Size(131, 33);
            this.lbUserName.Style = Sunny.UI.UIStyle.Custom;
            this.lbUserName.TabIndex = 91;
            this.lbUserName.Text = "未登录";
            this.lbUserName.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            this.lbUserName.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // uiSymbolLabel2
            // 
            this.uiSymbolLabel2.Dock = System.Windows.Forms.DockStyle.Fill;
            this.uiSymbolLabel2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.uiSymbolLabel2.ForeColor = System.Drawing.Color.White;
            this.uiSymbolLabel2.ImageInterval = 6;
            this.uiSymbolLabel2.Location = new System.Drawing.Point(278, 4);
            this.uiSymbolLabel2.MinimumSize = new System.Drawing.Size(1, 1);
            this.uiSymbolLabel2.Name = "uiSymbolLabel2";
            this.uiSymbolLabel2.Padding = new System.Windows.Forms.Padding(36, 0, 0, 0);
            this.uiSymbolLabel2.Size = new System.Drawing.Size(129, 24);
            this.uiSymbolLabel2.Style = Sunny.UI.UIStyle.Custom;
            this.uiSymbolLabel2.Symbol = 362306;
            this.uiSymbolLabel2.SymbolColor = System.Drawing.Color.White;
            this.uiSymbolLabel2.TabIndex = 42;
            this.uiSymbolLabel2.Text = "PLC状态";
            this.uiSymbolLabel2.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // uiCimStatue
            // 
            this.uiCimStatue.Dock = System.Windows.Forms.DockStyle.Fill;
            this.uiCimStatue.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.uiCimStatue.ForeColor = System.Drawing.Color.White;
            this.uiCimStatue.ImageInterval = 6;
            this.uiCimStatue.Location = new System.Drawing.Point(414, 4);
            this.uiCimStatue.MinimumSize = new System.Drawing.Size(1, 1);
            this.uiCimStatue.Name = "uiCimStatue";
            this.uiCimStatue.Padding = new System.Windows.Forms.Padding(36, 0, 0, 0);
            this.uiCimStatue.Size = new System.Drawing.Size(122, 24);
            this.uiCimStatue.Style = Sunny.UI.UIStyle.Custom;
            this.uiCimStatue.Symbol = 57388;
            this.uiCimStatue.SymbolColor = System.Drawing.Color.White;
            this.uiCimStatue.TabIndex = 92;
            this.uiCimStatue.Text = "Remote";
            this.uiCimStatue.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            // 
            // lbCimStatus
            // 
            this.lbCimStatus.AutoSize = true;
            this.lbCimStatus.Dock = System.Windows.Forms.DockStyle.Fill;
            this.lbCimStatus.Font = new System.Drawing.Font("Tahoma", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lbCimStatus.ForeColor = System.Drawing.Color.Red;
            this.lbCimStatus.Location = new System.Drawing.Point(414, 32);
            this.lbCimStatus.Name = "lbCimStatus";
            this.lbCimStatus.Size = new System.Drawing.Size(122, 33);
            this.lbCimStatus.Style = Sunny.UI.UIStyle.Custom;
            this.lbCimStatus.StyleCustomMode = true;
            this.lbCimStatus.TabIndex = 93;
            this.lbCimStatus.Text = "OFF";
            this.lbCimStatus.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
            this.lbCimStatus.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.lbCimStatus.DoubleClick += new System.EventHandler(this.lbCimStatus_DoubleClick);
            // 
            // tableLayoutPanel2
            // 
            this.tableLayoutPanel2.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Inset;
            this.tableLayoutPanel2.ColumnCount = 1;
            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel2.Controls.Add(this.btnLogin, 0, 0);
            this.tableLayoutPanel2.Controls.Add(this.btnOnOffline, 0, 1);
            this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Right;
            this.tableLayoutPanel2.Location = new System.Drawing.Point(1052, 0);
            this.tableLayoutPanel2.Margin = new System.Windows.Forms.Padding(0);
            this.tableLayoutPanel2.Name = "tableLayoutPanel2";
            this.tableLayoutPanel2.RowCount = 2;
            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
            this.tableLayoutPanel2.Size = new System.Drawing.Size(120, 66);
            this.tableLayoutPanel2.TabIndex = 101;
            // 
            // btnLogin
            // 
            this.btnLogin.Cursor = System.Windows.Forms.Cursors.Hand;
            this.btnLogin.Dock = System.Windows.Forms.DockStyle.Fill;
            this.btnLogin.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.btnLogin.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.btnLogin.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.btnLogin.Location = new System.Drawing.Point(2, 2);
            this.btnLogin.Margin = new System.Windows.Forms.Padding(0);
            this.btnLogin.MinimumSize = new System.Drawing.Size(1, 1);
            this.btnLogin.Name = "btnLogin";
            this.btnLogin.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.btnLogin.Size = new System.Drawing.Size(116, 30);
            this.btnLogin.Style = Sunny.UI.UIStyle.Custom;
            this.btnLogin.StyleCustomMode = true;
            this.btnLogin.Symbol = 57452;
            this.btnLogin.TabIndex = 102;
            this.btnLogin.Text = "Login";
            this.btnLogin.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.btnLogin.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.btnLogin.Click += new System.EventHandler(this.btnLogin_Click);
            // 
            // btnOnOffline
            // 
            this.btnOnOffline.Cursor = System.Windows.Forms.Cursors.Hand;
            this.btnOnOffline.Dock = System.Windows.Forms.DockStyle.Fill;
            this.btnOnOffline.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.btnOnOffline.Font = new System.Drawing.Font("微软雅黑", 12F);
            this.btnOnOffline.Location = new System.Drawing.Point(2, 34);
            this.btnOnOffline.Margin = new System.Windows.Forms.Padding(0);
            this.btnOnOffline.MinimumSize = new System.Drawing.Size(1, 1);
            this.btnOnOffline.Name = "btnOnOffline";
            this.btnOnOffline.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(85)))), ((int)(((byte)(85)))), ((int)(((byte)(85)))));
            this.btnOnOffline.Size = new System.Drawing.Size(116, 30);
            this.btnOnOffline.Style = Sunny.UI.UIStyle.Custom;
            this.btnOnOffline.StyleCustomMode = true;
            this.btnOnOffline.Symbol = 361612;
            this.btnOnOffline.TabIndex = 103;
            this.btnOnOffline.Text = "on/offline";
            this.btnOnOffline.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.btnOnOffline.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0);
            this.btnOnOffline.Click += new System.EventHandler(this.btnOnOffline_Click);
            // 
            // MainTopPanel
            // 
            this.BackColor = System.Drawing.Color.Beige;
            this.Name = "MainTopPanel";
            this.Size = new System.Drawing.Size(1172, 66);
            this.panelBack.ResumeLayout(false);
            this.panelContent.ResumeLayout(false);
            this.tableLayoutPanel1.ResumeLayout(false);
            this.tableLayoutPanel1.PerformLayout();
            this.tableLayoutPanel2.ResumeLayout(false);
            this.ResumeLayout(false);

        }

        private void lbCimStatus_DoubleClick(object sender, EventArgs e)
        {
            LifterSEM lifterCim = (LifterSEM)Naming.GetDeviceManager().GetDevice();
            if (lbUserName.Text == "未登录")
            {
                PopupNotice.DialogPopups("Lifter未登录. 不能改变Cim状态！！！", "Lifter is the UNLAND state Cannot change to CIM status!!!", enumPopupsType.Warning);
                return;
            }
            if (lblPLCConnection.Text == "Disconnected")
            {
                PopupNotice.DialogPopups("Plc未连接. 不能改变Cim状态！！！", "Plc is the DISCONNECTED state Cannot change to CIM status!!!", enumPopupsType.Warning);
                return;
            }
            if (!lifterCim.CimStatusChangeEnableFlag)
            {
                PopupNotice.DialogPopups("设备目前状态不允许切换CIM状态，请确认设备状态！！！", "The current status of the device does not allow switching to CIM status. Please confirm the device status!!!", enumPopupsType.Warning);
                return;
            }
            if (lbCimStatus.Text == "ON")
            {
                lifterCim.O_CIMSTATUSCHANGEVALUE = 2;
                LogHelper.operationLogger(string.Format("用户[{0}]进行了设备CIMOFF模式切换操作", this.hostDevice.UserName));
                lifterCim.InsertUserOperation(lifterCim.UserName, string.Format("用户[{0}]进行了设备CIMOFF模式切换操作", this.hostDevice.UserName));
            }
            else
            {
                lifterCim.O_CIMSTATUSCHANGEVALUE = 1;
                LogHelper.operationLogger(string.Format("用户[{0}]进行了设备CIMON模式切换操作", this.hostDevice.UserName));
                lifterCim.InsertUserOperation(lifterCim.UserName, string.Format("用户[{0}]进行了设备CIMON模式切换操作", this.hostDevice.UserName));
            }
            lifterCim.O_CIMSTATUSCHANGE = true;
            Thread.Sleep(1000);
            lifterCim.O_CIMSTATUSCHANGE = false;
        }

        private void uiSmoothLabel2_DoubleClick(object sender, EventArgs e)
        {
            LifterMainForm lifterMainForm = (LifterMainForm)SimpleCache.GetObject("FormMain", "LifterMainForm");
            lifterMainForm.WindowState = FormWindowState.Minimized;
        }
    }
}
